package com.study.zzedu.widget;

import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Color;
import android.util.AttributeSet;
import android.util.TypedValue;
import android.view.View;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.study.zzedu.R;

public class VersionInfoItem extends RelativeLayout {

    /*左侧显示文本*/
    private String mLeftText;
    public String mRightText;
    public VersionInfoItem(Context context) {
        this(context,null);
    }

    public VersionInfoItem(Context context, AttributeSet attrs) {
       this(context,attrs,0);
    }

    public VersionInfoItem(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        initView(context);
        getCustomStyle(context,attrs);
    }

    /*整体根布局view*/
    private View mView;
    public TextView tvTitile,tvInfo;
    private void initView(Context context){
        mView = View.inflate(context, R.layout.version_item,this);
        tvTitile = (TextView)mView.findViewById(R.id.tv_title);
        tvInfo = (TextView)mView.findViewById(R.id.tv_info);
    }

    private void getCustomStyle(Context context,AttributeSet attrs){
        TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.LLSettingView);
        int n = a.getIndexCount();
        for (int i = 0; i < n; i++) {
            int attr = a.getIndex(i);
            if (attr == R.styleable.LLSettingView_mleftText) {
                mLeftText = a.getString(attr);
                tvTitile.setText(mLeftText);
            }  else if (attr == R.styleable.LLSettingView_mrightText) {
                mRightText = a.getString(attr);
                tvInfo.setText(mRightText);
            }
//            else if (attr == R.styleable.LSettingView_isShowUnderLine) {
//                //默认显示分割线
//                if (!a.getBoolean(attr, true)) {
//                    mUnderLine.setVisibility(View.GONE);
//                }
//            }
        }
        a.recycle();


    }
}
